package com.hns.can.service.service;

import com.hns.can.service.vo.SecurityGradeVo;
import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.service.BaseInfoValueService;
import com.hns.can.common.vo.CommonParamsVo;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 违章事故考核Service
 * @author:zhangzq
 * @email:
 * @version Revision 2.0.0
 */
@Service
public class SecurityGradeService extends CommonService {

    @Autowired
    private BaseInfoValueService baseInfoValueService;

    /**
     * 分页查询违章事故考核数据
     * @param vo
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @LeftOrgAnnotation()
    @Transactional
    public Pagination searchSecurityBehaviour(CommonParamsVo vo) throws Exception {
        Pagination page = this.myBatisPage("securityGrade.getSecurityCount", "securityGrade.getSecurityGrade", vo, SecurityGradeVo.class);
        List<Object> list = page.getData();
        baseInfoValueService.fillOrganLineDrvName(list);
        page.setData(list);
        return page;
    }

    /**
     * 查询违章事故考核数据用于导出
     * @param vo
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @LeftOrgAnnotation()
    @Transactional
    public List<SecurityGradeVo> getSecurityGradeInfo(CommonParamsVo vo) throws Exception {
        List<SecurityGradeVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("securityGrade.getSecurityGrade", vo), SecurityGradeVo.class);
        baseInfoValueService.fillOrganLineDrvName(list);
        return list;
    }
}
